Skip to content

UI: Use custom HTML elements for the UI Tag Input#11715

Open
lscharmer wants to merge 1 commit into
ILIAS-eLearning:release_11from
lscharmer:11/hotfix/ui-tag-input
Open

UI: Use custom HTML elements for the UI Tag Input#11715
lscharmer wants to merge 1 commit into
ILIAS-eLearning:release_11from
lscharmer:11/hotfix/ui-tag-input

Conversation

@lscharmer

Copy link
Copy Markdown
Contributor

This PR fixes Mantis Bugs:

The library @yaireo/tagify which is used for the UI Tag Input uses non existing HTML tags (e.g. <tags>, <tag>). We already replaced these with <div>'s instead but this results in invalid attributes used for our replacement tags (as reported in the Mantis issues above).

This PR replaces the <div>'s with custom HTML elements, so that this won't result in invalid HTML attributes anymore (https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_custom_elements).

@lscharmer
lscharmer requested a review from thibsy July 1, 2026 09:48
@lscharmer lscharmer added bugfix javascript Pull requests that update Javascript code labels Jul 1, 2026

@thibsy thibsy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @lscharmer,

Thx for providing this fix.

This is another good example of why the @yaiero/tagify library keeps causing friction. We repeatedly work around some issues or limitations to bend this library to all our needs, which keeps trading one problem for another and adds much unnecessary complexity. We should get rid of this library short-term.

For this PR specifically, please help me answer the following questions:

  • Isn't there an existing element that supports all attributes the library needs? Maybe even an <input type="hidden"> (although this might be tricky due to name etc.)?
  • If I remember correctly, we originally moved to a div because the custom HTML tag of the library was flagged during an A11Y inspection or some HTML-validator run (not entirely sure though). Would we not simply cause this issue again, since we embed a custom HTML tag of our own?

Thx for your insight.

Kind regards,
@thibsy (as UI coordinator)

@lscharmer

Copy link
Copy Markdown
Contributor Author

Hi @thibsy,
thanks for the feedback.

This is another good example of why the @yaiero/tagify library keeps causing friction. We repeatedly work around some issues or limitations to bend this library to all our needs, which keeps trading one problem for another and adds much unnecessary complexity. We should get rid of this library short-term.

I agree, AFAIK we also just need a fraction of the functionality the library provides.

Isn't there an existing element that supports all attributes the library needs? Maybe even an (although this might be tricky due to name etc.)?

The ui-tag-input can be replaced with a button element, in terms of attribute and sematic context (but with some custom CSS). I will update the PR.
But not the other two:
The ui-tag-dropdown-item requires the attribute tagifySuggestionIdx which is invalid for all existing HTML elements and the ui-tags-input requires attributes like readonly, disabled but also children, for which I could not find any matching elements.

If I remember correctly, we originally moved to a div because the custom HTML tag of the library was flagged during an A11Y inspection or some HTML-validator run (not entirely sure though). Would we not simply cause this issue again, since we embed a custom HTML tag of our own?

No, because the problem with the tagify library is that they don't use valid custom elements.
Custom HTML elements MUST contain a dash (-) (https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name).
The tagify library simply uses <tags> etc. which is invalid.

If I read this correctly they don't need to be defined with window.customElements.define(...) but it is best practice, so I added it (https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_custom_elements).

I also tested the custom elements with the W3C HTML Validator which was used for the failed TestRail Cases (at least for the linked Mantis Issues). No issues are reported with the custom elements (with a dash) + attributes.

Best regards
@lscharmer

@thibsy

thibsy commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Hi @lscharmer,

Thx a lot for the explanation. I was not aware of how custom HTML tags work exactly. From my POV there is no need to replace the one tag with a button then. I want as little overhead as possible. You could even remove the tags registration then, since its optional.

Let me know if I should integrate this as is.

Kind regards,
@thibsy (as UI coordinator)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix javascript Pull requests that update Javascript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants